(function(){
	var timer='<div id="datetime">{{timer | date}}&nbsp;{{timer | week}}</div>'
	var timeArea=Vue.extend({
		template:timer,
//		props:{
//			active_model:[String,Number],
//			platform_name:String,
//			require:true,
//		},
		data:function(){
			return{
				timer:new Date()
			}
		},
		filters:{
			date:function(val){
				var tamp=val.getTime();        //获取当前时间戳
				var time = new Date(tamp);
            	var y = time.getFullYear();       //获取年
           		var m = time.getMonth()+1;        //获取月
           		var d = time.getDate();          //获取日
           		var timedat=new Date(y+'-'+m+'-'+d);           //根据当前日期获取星期几 
           		var week;
          		if(timedat.getDay() == 0) week = "星期日";
          		if(timedat.getDay() == 1) week = "星期一";
          		if(timedat.getDay() == 2) week = "星期二";
          		if(timedat.getDay() == 3) week = "星期三";
          		if(timedat.getDay() == 4) week = "星期四";
          		if(timedat.getDay() == 5) week = "星期五";
          		if(timedat.getDay() == 6) week = "星期六";
          		return y+'年'+m+'月'+d+'日';
			},
			week:function(val){
				var tamp=val.getTime();        //获取当前时间戳
				var time = new Date(tamp);
            	var y = time.getFullYear();       //获取年
           		var m = time.getMonth()+1;        //获取月
           		var d = time.getDate();          //获取日
           		var timedat=new Date(y+'-'+m+'-'+d);           //根据当前日期获取星期几 
           		var week;
          		if(timedat.getDay() == 0) week = "星期日";
          		if(timedat.getDay() == 1) week = "星期一";
          		if(timedat.getDay() == 2) week = "星期二";
          		if(timedat.getDay() == 3) week = "星期三";
          		if(timedat.getDay() == 4) week = "星期四";
          		if(timedat.getDay() == 5) week = "星期五";
          		if(timedat.getDay() == 6) week = "星期六";
          		return week;
			}
		},
		mounted() {
		    let _this = this; // 声明一个变量指向Vue实例this，保证作用域一致
		    this.date=setInterval(function(){
		    	_this.timer = new Date();
		    },1000)
	    },
	})
	window.timer_area = timeArea
})()
